#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using ll = long long;
ll kmi(ll a,ll k)
{
    ll res=1;
    while(k)
    {
        if(k&1)
        res*=a;
        a *= a;
        k >>= 1;
    }
    return res;
}
void solve()
{
    // 
    ll n;
    cin >> n;
    vector<ll> er;
    while(n)
    {
        er.push_back(n%2);
        n/=2;
    }
    // for(auto i:er)
    // {
    //     cout << i << " ";
    // }
    ll now=er.size();
    cout << kmi(2, now)-1;
}
int main()
{
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
